﻿Friend Class SettingsControl
    Implements Framework.Settings.ISettingsControl

    Private Sub AfterClose() Implements Framework.Settings.ISettingsControl.AfterClose
    End Sub

    Private Sub BeforeShow() Implements Framework.Settings.ISettingsControl.BeforeShow
    End Sub

    Private ReadOnly Property DisplayImage() As System.Drawing.Image Implements Framework.Settings.ISettingsControl.DisplayImage
        Get
            Return My.Resources.harddisc_xp.ToBitmap
        End Get
    End Property

    Private ReadOnly Property DisplayName() As String Implements Framework.Settings.ISettingsControl.DisplayName
        Get
            Return "Backup"
        End Get
    End Property

    Private Function GetUserControl() As System.Windows.Forms.UserControl Implements Framework.Settings.ISettingsControl.GetUserControl
        Return Me
    End Function

    Private ReadOnly Property Key() As String Implements Framework.Settings.ISettingsControl.Key
        Get
            Return "Backup"
        End Get
    End Property

    Private mStartFilter As String
    Private Sub LoadSettings() Implements Framework.Settings.ISettingsControl.LoadSettings
        mStartFilter = Framework.Serialization.ToXml(Engine.Settings.GlobalFileFilter)
        FileFilterControl1.SetFilter(Engine.Settings.GlobalFileFilter, True)
        txtWorkingFolder.Text = Engine.Settings.WorkingFolder
    End Sub

    Private Function NeedsSave() As Boolean Implements Framework.Settings.ISettingsControl.NeedsSave
        Dim strNow As String = Framework.Serialization.ToXml(FileFilterControl1.GetFilter)
        If strNow <> mStartFilter Then Return True
        If txtWorkingFolder.Text <> Engine.Settings.WorkingFolder Then Return True
        Return False
    End Function

    Private Sub SaveCompleted() Implements Framework.Settings.ISettingsControl.SaveCompleted
    End Sub

    Private Sub SaveSettings(ByVal transactionScope As Framework.Data.TransactionScope) Implements Framework.Settings.ISettingsControl.SaveSettings
        Engine.Settings.SetGlobalFileFilter(FileFilterControl1.GetFilter(), transactionScope)
        Engine.Settings.SetWorkingFolder(txtWorkingFolder.Text, transactionScope)
    End Sub

    Private Sub ValidateSettings(ByVal errorProvider As Framework.ErrorHandling.ErrorProviderEx) Implements Framework.Settings.ISettingsControl.ValidateSettings
    End Sub
End Class
